package com.itheima.demo.demo03.demo04;

import java.util.*;

public class DouDiZhu {
    public static void main(String[] args) {
        //使用双列Map(HashMap)集合，完成一个数字与字符串纸牌的对应关系(相当于一个字典)。
     Map<Integer,String>poker=new HashMap<>();
        //创建一个List集合,存储牌的索引
        ArrayList<Integer>pokerindex=new ArrayList<>();
        //定义两个集合,存储花色和牌的序号
        List<String>colors=List.of("黑桃","红心","梅花","方片");
        List<String>numbers=List.of("2", "A", "K", "Q", "J", "10", "9", "8", "7", "6", "5", "4", "3");
       int index=0;
       poker.put(index,"大王");
       pokerindex.add(index);
       index++;
        poker.put(index,"小王");
        pokerindex.add(index);
        index++;
       for (String color : colors) {
            for (String number : numbers) {
                poker.put(index,color+number);
                pokerindex.add(index);
                index++;
            }
        }
       // System.out.println(poker);
       // System.out.println(pokerindex);
        Collections.shuffle(pokerindex);
        System.out.println(poker);
        //发牌，创建4个集合，
        ArrayList<Integer>player1=new ArrayList<>();
        ArrayList<Integer>player2=new ArrayList<>();
        ArrayList<Integer>player3=new ArrayList<>();
        ArrayList<Integer>dipai=new ArrayList<>();
        for (int i = 0; i < pokerindex.size(); i++) {
            Integer inter = pokerindex.get(i);
            if(i>50){
                dipai.add(inter);
            }else if(i%3==0){
                player1.add(inter);
            }else if(i%3==1){
                player2.add(inter);
            }else if(i%3==2){
                player3.add(inter);
            }
        }
        Collections.sort(player1);
        Collections.sort(player2);
        Collections.sort(player3);
        Collections.sort(dipai);
        System.out.println(player1);
        System.out.println(player2);
        System.out.println(player3);
        System.out.println(dipai);
        Set<Integer> set = poker.keySet();




    }
}
